#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "esp_log.h"
#include "Com_Debug.h"
#include "App_IO.h"
#include "App_Communication.h"

// #define tag_t "main"

void KeyScanTask(void *args);

TaskHandle_t key_scan_task_handle;

void FingerScanTask(void *args);

TaskHandle_t finger_scan_task_handle;

void OTATask(void *args);

TaskHandle_t ota_task_handle;

void app_main(void)
{

    MY_LOGE("智能门锁1.0");
    MY_LOGD("123456");
    MY_LOGD("777777")
    MY_LOGD("666666");



    App_IO_Start();

    App_Communication_Start();
    // App_Communication_OTA();

    // 创建按键扫描任务
    xTaskCreate(KeyScanTask, "KeySacnTask", 4096, NULL, 5, &key_scan_task_handle);

    // 创建指纹扫描任务
    xTaskCreate(FingerScanTask, "FingerScanTask", 4096, NULL, 5, &finger_scan_task_handle);

    // 创建OTA任务
    xTaskCreate(OTATask, "OTATask", 4096, NULL, 5, &ota_task_handle);

    return; // 主任务返回，框架会删除主任务
}

void KeyScanTask(void *args)
{
    MY_LOGI("按键扫描任务开始调度");

    while (1)
    {
        App_IO_TouchKeyScan();
    }
}

void FingerScanTask(void *args)
{
    MY_LOGI("指纹扫描任务开始调度");

    while (1)
    {
        App_IO_FingerScan();
    }
}

void OTATask(void *args)
{
    MY_LOGI("OTA任务开始调度");

    while (1)
    {
        App_Communication_OTA();
    }
}
